package com.sync.utils.project.demo.pojo;

import com.sync.utils.common.validation.Groups;
import com.sync.utils.common.validation.annotation.StrictID;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.Valid;
import javax.validation.constraints.*;
import java.io.Serializable;

/**
 * TODO
 *
 * @Author YWF
 * @Date 2023/3/29 17:29
 */
@Data
public class UserReq {

    @NotNull(groups = {Groups.Update.class,Groups.Create.class },message = "用户ID不能为空")
    @StrictID(groups = {Groups.Update.class,Groups.Create.class })
    private String userId;

    @NotNull
    @Length(min = 2, max = 10, message = "用户名长度应为2-20个字符")
    private String userName;

    @NotNull(groups = {Groups.Update.class,Groups.Create.class })
    @Length(min = 6, max = 20, message = "账号长度应为6-20个字符", groups = {Groups.Update.class,Groups.Create.class })
    private String account;

    @NotNull
    @Email(regexp = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", message = "请输入有效的电子邮件地址")
    private String email;

    @Pattern(regexp = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[a-zA-Z\\d]{8,}$",
            message = "密码必须包含大小写字母和数字，且至少8个字符")
    private String password;

    @Min(value = 18, message = "年龄必须大于或等于18岁")
    @Max(value = 120, message = "年龄必须小于或等于120岁")
    private Integer age;


    private Integer pageSize;

    private Integer pageNum;

    private String status;

    @NotNull(groups = {Groups.Create.class}, message = "工作信息不能为空")
    @Valid
    private Job job;

    @Data
    public static class Job {

        @Min(value = 1, groups = Groups.Create.class, message = "工作ID最小值为1")
        private Long jobId;

        @NotNull(groups = {Groups.Create.class}, message = "工作名称不能为空")
        @Length(min = 2, max = 10, groups = {Groups.Create.class}, message = "工作名称必须为2~10个字符")
        private String jobName;

        @NotNull(groups = {Groups.Create.class}, message = "职位名称不能为空")
        @Length(min = 2, max = 10, groups = {Groups.Create.class}, message = "职位名称必须为2~10个字符")
        private String position;
    }

}
